package xrz.cuanbao.activity;

import java.util.List;

import org.xutils.x;
import org.xutils.common.Callback.CancelledException;
import org.xutils.common.Callback.CommonCallback;
import org.xutils.view.annotation.ViewInject;

import com.xrz.sxm.base.activity.BaseAct;
import com.xrz.sxm.base.utils.ScreenUtil;

import android.graphics.drawable.Drawable;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import xrz.cuanbao.R;

public class Act_RenRenCuanItemZuoPin extends BaseAct {
	@ViewInject(R.id.item_zuopin_webview)
	private LinearLayout linearLayout;

	@Override
	protected int setContentView() {
		return R.layout.layout_renrencuanitemzuopin;
	}

	@Override
	protected void initData() {
		List<String> pics = (List<String>) getIntent().getSerializableExtra("list");
		for(String str:pics){
			ImageView view = createImageView(str);
			linearLayout.addView(view);
		}
	}


	private ImageView createImageView(String str) {
		final ImageView imageView = new ImageView(m_ctx);
		x.image().bind(imageView, str, new CommonCallback<Drawable>() {
			
			@Override
			public void onSuccess(Drawable arg0) {
				int width = arg0.getIntrinsicWidth();
				int hight = arg0.getIntrinsicHeight();
				int newWidth = ScreenUtil.getInstant().getDisWidth(m_ctx);
				int newHight = newWidth * hight / width;
				imageView.setLayoutParams(new LayoutParams(newWidth, newHight));
				imageView.setImageDrawable(arg0);
			}
			
			@Override
			public void onFinished() {
				
			}
			
			@Override
			public void onError(Throwable arg0, boolean arg1) {
				
			}
			
			@Override
			public void onCancelled(CancelledException arg0) {
				
			}
		});
		return imageView;
	}

	@Override
	protected String setTitle() {
		return null;
	}

	@Override
	protected boolean topViewHide() {
		return true;
	}

}
